<style>
.btn.btn-success-o{
    background: #fff;
    border: 1px solid {{main.syscolor||'#05c175'}};
    color: {{main.syscolor||'#05c175'}};
}
.btn.btn-success-o.active{
    background: {{main.syscolor||'#05c175'}};
    border: 1px solid {{main.syscolor||'#05c175'}};
    color: #fff;
}
.btn.btn-success-o.active .subtitle{
    color: #f2f2f2;
}
</style>
<div ng-if="pagedata.apply.agree==1 && !pagedata.show_content" class='fui-page fui-page-current page-commission-register'>
    <div class="fui-header">
        <div class="fui-header-left">
            <a class="back" ng-click='goback()'></a>
        </div>
        <div class="title">申请加入我们</div>
        <div class="fui-header-right"></div>
    </div>
	<div class='fui-content'>
        <img style='width:100%;position: relative' ng-src="{{tomedia(pagedata.apply_setting.regbg) || '../addons/jy_ylfee/resource/images/bg.png'}}" />
		<div ng-if="pagedata.member.stop==1" class='content-empty' >
            <i class='icon icon-info text-danger'></i>
            <br/><span class="text-danger">禁止访问，请联系客服！</span>
            <br/><a ng-if="pagedata.index_url" class="btn btn-danger" href="javascript:;" ng-click="access_json(pagedata.index_url)">去商城逛逛</a>
        </div>
        <div ng-if="(!pagedata.apply.id || pagedata.applyagain || pagedata.apply.needpay==1) && pagedata.become==2 && pagedata.member.stop!=1">
        <div class="fui-cell-group" style='margin-top:0'>
            <div class="fui-cell-title">
                欢迎加入<span class='text-danger'>{{pagedata.apply_setting.shop_title}}</span>，请填写申请信息
            </div>
            <div class='fui-cell must'>
                <div class='fui-cell-label'>姓名</div>
                <div class='fui-cell-info'><input type="text" class='fui-input' ng-model="pagedata.apply.realname" placeholder="请填写真实姓名，用于结算" /></div>
            </div>
            <div class="fui-cell must ">
				<div class="fui-cell-label ">手机号</div>
				<div class="fui-cell-info"><input type="text" class='fui-input' placeholder="设置手机号" ng-model="pagedata.apply.mobile" /></div>
				<div ng-if="pagedata.apply.login_type>0 && !pagedata.bindmobile && pagedata.apply.oldmobile" class="fui-cell-remark noremark"><a class="btn btn-default btn-default-o btn-sm" ng-click="pagedata.bindmobile=true;pagedata.apply.mobile=''">解绑手机</a></div>
				<div ng-if="pagedata.apply.login_type>0 && (pagedata.bindmobile || !pagedata.apply.oldmobile)" class="fui-cell-remark noremark"><a class="btn btn-default btn-default-o btn-sm" ng-click="tool.mobile_code(pagedata.apply.mobile,'sms_code')" id="sms_code">获取验证码</a></div>
			</div>
			<div ng-if="pagedata.apply.login_type>0 && (pagedata.bindmobile || !pagedata.apply.oldmobile)" class="fui-cell must ">
				<div class="fui-cell-label ">验证码</div>
				<div class="fui-cell-info"><input type="text" class='fui-input' placeholder="请输入验证码" ng-model="pagedata.apply.smscode" /></div>
			</div>
            <div ng-if="pagedata.member.is_agent!=1" class='fui-cell'>
                <div class='fui-cell-label'>微信号</div>
                <div class='fui-cell-info'><input type="text" class='fui-input' ng-model="pagedata.apply.wechat" placeholder="请填写微信号"  /></div>
            </div>
			<div class='fui-cell'>
                <div class='fui-cell-label'>申请级别</div>
                <div class="fui-cell-info">
					<select class="weui_select" ng-model="pagedata.apply.level_type" ng-change="pagedata.upopenfee()"name="type" style="background:#f2f2f2;padding:0.2rem;height:auto">
						<option ng-repeat="(k,item) in pagedata.level_types" ng-selected="pagedata.apply.level_type==item.key" value="{{item.key}}">{{item.title}}</option>
					</select>
				</div>
            </div>
			<div class="fui-cell">
				<div class="fui-cell-label">申请地区</div>
				<div ng-if="pagedata.apply.level_type==0 && pagedata.apptype==1" class="fui-cell-info">{{pagedata.apply.province2}} {{pagedata.apply.city2}}</div>
				<div ng-if="pagedata.apply.level_type>0 || pagedata.apptype!=1" class="fui-cell-label" style="width:50%">
					<select ng-model="pagedata.apply.province" class="form-control tpl-province">
						<option value="" selected="selected">省份</option>
						<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.apply.province==value">{{value}}</option>
					</select>
				</div>
				<div ng-if="pagedata.apply.level_type<=1 && (pagedata.apply.level_type>0 || pagedata.apptype!=1)" class="fui-cell-label" style="width:50%">
					<select ng-model="pagedata.apply.city" class="form-control tpl-city">
						<option value="" selected="selected">城市</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.apply.province]" value="{{value}}" ng-selected="pagedata.apply.city==value">{{value}}</option>
					</select>
				</div>
			</div>
			<div ng-if="pagedata.apply.level_type<=1"  class="fui-cell">
				<div class="fui-cell-label">邮寄地区</div>		
				<div class="fui-cell-label" style="width:50%">
								<select ng-model="pagedata.apply.redpcd.province" class="form-control tpl-province">
								<option value="" selected="selected">省份</option>
								<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.apply.redpcd.province==value">{{value}}</option>
								</select>
				</div>
				<div class="fui-cell-label" style="width:50%">
								<select ng-model="pagedata.apply.redpcd.city" class="form-control tpl-city">
								<option value="" selected="selected">城市</option>
								<option ng-repeat="(value,data) in pagedata.province[pagedata.apply.redpcd.province]" value="{{value}}" ng-selected="pagedata.apply.redpcd.city==value">{{value}}</option>
								</select>
				</div>
			</div>
			<div ng-if="pagedata.apply.level_type<=1" class="fui-cell">
				<div class='fui-cell-info'><input type="text" class='fui-input' ng-model="pagedata.apply.address" placeholder="请填写详细邮寄地址"  /></div>
			</div>
            <div class="fui-cell-group">
                <div class="fui-cell small ">
                    <div class="fui-cell-info">
                        <label class="checkbox-inline">
                            <input type="checkbox" class="fui-checkbox-primary" ng-model="pagedata.apply.agree" ng-checked="pagedata.apply.agree==1"/> 我已经阅读并了解了<a id="btn-apply" ng-click="pagedata.show_content=true" style="color:#337ab7;">【{{pagedata.xieyi[pagedata.apply.level_type].title || '代理协议'}}】</a>。
                        </label>

                    </div>
                </div>

            </div>
        </div>
		<div ng-if="!pagedata.apply.openfee || pagedata.apply.openfee<=0" class='btn btn-danger block btn-submit' style="margin-top:2rem" ng-click="post(pagedata.apply,'/apply/post/')">提交申请</div>
		<div ng-if="pagedata.apply.openfee>0" class='btn btn-danger block btn-submit' style="margin-top:2rem" ng-click="pagedata.payfee()">￥{{pagedata.apply.openfee||'0.00'}} 提交申请</div>
		</div>
		<div ng-if="pagedata.apply.id && pagedata.apply.needpay!=1 && !pagedata.applyagain" class='fui-content'>
			<div ng-if="pagedata.apply.status==0" class='content-info' >
				<i class='icon icon-clock'></i>
				<br/><span class="">谢谢您的支持，请等待审核！</span>
				<br/><a ng-if="pagedata.index_url" class="btn btn-danger" href="javascript:;" ng-click="access_json(pagedata.index_url)">去商城逛逛</a>
			</div>
			<div ng-if="pagedata.apply.status==1 && pagedata.member.is_agent!=1" class='content-info' >
				<i class='icon icon-clock'></i>
				<br/><span class="">您的代理商身份已经清空！无法再申请代理商！</span>
				<br/><a ng-if="pagedata.index_url" class="btn btn-danger" href="javascript:;" ng-click="access_json(pagedata.index_url)">去商城逛逛</a>
			</div>
			<div ng-if="pagedata.apply.status==1 && pagedata.member.is_agent==1" class='content-info' >
				<i class='icon icon-clock'></i>
				<br/><span class="">恭喜您，您的代理申请已审核通过！</span>
				<br/><a class="btn btn-danger" href="javascript:;" ng-click="access_json('jy_ylfee/index/')">前往代理中心</a>
			</div>
			<div ng-if="pagedata.member.is_agent==2 || pagedata.apply.status==2" class='content-info' >
				<i class='icon icon-clock'></i>
				<br/><span class="">非常抱歉，您的代理申请被管理员拒绝！</span>
				<br/><span class="">未审核通过原因：</span>
				<br/><span class="subtitle">{{pagedata.apply.remark || '无'}}</span>
				<br/><a class="btn btn-danger" href="javascript:;" ng-click="pagedata.applyagain=1">重新申请</a>
			</div>
		</div>
    </div>
</div>
<div ng-if="pagedata.apply.agree!=1 || pagedata.show_content" class='fui-page fui-page-current' id="xieyi" style="z-index:10;">
    <div class="fui-content">
		<div class="content-images" style="padding:0.5rem;">
			<div class="title bold" style="font-size:0.8rem">{{pagedata.xieyi[pagedata.apply.level_type].title || '代理协议'}} / <small>Read Ggree</small></div>
			<div class="text" style="padding-top:0.5rem;font-size:0.7rem" ng-bind-html="trust(pagedata.xieyi[pagedata.apply.level_type].content)">
			</div>
		</div>
		<div class="modal-footer fui-footer" style="height:auto">
			<div ng-click="access_json(pagedata.index_url)" class="mod-fail">不同意</div>
			<div ng-if="pagedata.nowmiao==0 && pagedata.istodown" ng-click="pagedata.apply.agree=1;pagedata.show_content=false" class="mod-success">我已阅读并同意</div>
			<div ng-if="pagedata.nowmiao!=0 || !pagedata.istodown" class="mod-success" style="background: #e6e6e6;">请先阅读完<span ng-if="pagedata.nowmiao!=0 && pagedata.istodown">({{pagedata.nowmiao}})</span></div>
		</div>
	</div>
</div>
<script>
scope.pagedata.payfee=function(){
	scope.post_json('jy_ylfee/apply/post/',scope.pagedata.apply,function(pay_id){
		console.log('pay_id');console.log(pay_id);
		scope.tool.pay(pay_id,function(res){
				console.log('收到支付结果！');
				if(res.type=='success'){
					scope.message('申请成功！','','jy_ylfee/index/');
				}else{
					scope.message('申请失败！'+res.message,'','jy_ylfee/apply/');
				}
		},'','','jy_ylfee/index/');
	});
}
scope.pagedata.upopenfee=function(){
	scope.pagedata.apply.openfee=scope.pagedata.level_types[scope.pagedata.apply.level_type].openfee
	scope.$evalAsync();
}
scope.pagedata.scroll_bottom=function(){
	console.log('到达底部了！');
	scope.$evalAsync();
	if(!scope.pagedata.istodown){
		scope.pagedata.miaodown();
	}
	scope.pagedata.istodown=true;
}
// 设置倒计时的总秒数
const totalSeconds = 3;
scope.pagedata.nowmiao=3;
scope.pagedata.miaodown=function(){
	// 初始化倒计时
	let secondsRemaining = totalSeconds;
	const intervalId = setInterval(() => {
	  secondsRemaining--;
	 // 将秒数转换成时分秒的格式
	  const minutes = Math.floor(secondsRemaining / 60);
	  const seconds = secondsRemaining % 60;
	  scope.pagedata.nowmiao=secondsRemaining;
	   // 如果倒计时结束，清除定时器
	  if (secondsRemaining <= 0){
		clearInterval(intervalId);
	  }
	  scope.$evalAsync();
	}, 1000);
}
</script>